package fr.inria.phoenix.scenario.bwsnfirefighting.framework.distributed.deployment;

import fr.inria.diagen.core.ServiceConfiguration;
import fr.inria.diagen.core.service.local.Service;

import fr.inria.phoenix.scenario.bwsnfirefighting.framework.distributed.server.Server;
import fr.inria.phoenix.scenario.bwsnfirefighting.framework.distributed.environmentsensordevice.EnvironmentSensorDevice;
import fr.inria.phoenix.scenario.bwsnfirefighting.framework.distributed.sound.Sound;
import fr.inria.phoenix.scenario.bwsnfirefighting.framework.distributed.manualbutton.ManualButton;
import fr.inria.phoenix.scenario.bwsnfirefighting.framework.distributed.sprinkler.Sprinkler;
import fr.inria.phoenix.scenario.bwsnfirefighting.framework.distributed.light.Light;
import fr.inria.phoenix.scenario.bwsnfirefighting.framework.distributed.locateddevice.LocatedDevice;

import fr.inria.phoenix.scenario.bwsnfirefighting.framework.distributed.statusdetection.StatusDetection;
import fr.inria.phoenix.scenario.bwsnfirefighting.framework.distributed.temperaturedetection.TemperatureDetection;
import fr.inria.phoenix.scenario.bwsnfirefighting.framework.distributed.smokedetection.SmokeDetection;
import fr.inria.phoenix.scenario.bwsnfirefighting.framework.distributed.alertdetection.AlertDetection;
import fr.inria.phoenix.scenario.bwsnfirefighting.framework.distributed.buildingalertdetection.BuildingAlertDetection;

import fr.inria.phoenix.scenario.bwsnfirefighting.framework.distributed.alarmmanager.AlarmManager;
import fr.inria.phoenix.scenario.bwsnfirefighting.framework.distributed.logmanager.LogManager;
import fr.inria.phoenix.scenario.bwsnfirefighting.framework.distributed.messagemanager.MessageManager;


public abstract class MainDeploy {

  protected class Adder<T extends Service> {
    public void deploy(T component) {
  		component.initialize();  
    }
  }

  protected abstract void deployEnvironmentSensorDevices(Adder<EnvironmentSensorDevice> adder);
  protected abstract void deploySounds(Adder<Sound> adder);
  protected abstract void deployManualButtons(Adder<ManualButton> adder);
  protected abstract void deploySprinklers(Adder<Sprinkler> adder);
  protected abstract void deployLights(Adder<Light> adder);
  protected abstract void deployLocatedDevices(Adder<LocatedDevice> adder);

  protected abstract void deployStatusDetections(Adder<StatusDetection> adder);
  protected abstract void deployTemperatureDetections(Adder<TemperatureDetection> adder);
  protected abstract void deploySmokeDetections(Adder<SmokeDetection> adder);
  protected abstract void deployAlertDetections(Adder<AlertDetection> adder);
  protected abstract void deployBuildingAlertDetections(Adder<BuildingAlertDetection> adder);

  protected abstract void deployAlarmManagers(Adder<AlarmManager> adder);
  protected abstract void deployLogManagers(Adder<LogManager> adder);
  protected abstract void deployMessageManagers(Adder<MessageManager> adder);

  protected abstract ServiceConfiguration getServiceConfiguration();
  
  protected void deployServer() {
    new Server(getServiceConfiguration()).initialize();
  }

  public void deployAll() {
    deployServer();
  	deployEnvironmentSensorDevices(new Adder<EnvironmentSensorDevice>());
  	deploySounds(new Adder<Sound>());
  	deployManualButtons(new Adder<ManualButton>());
  	deploySprinklers(new Adder<Sprinkler>());
  	deployLights(new Adder<Light>());
  	deployLocatedDevices(new Adder<LocatedDevice>());

  	deployStatusDetections(new Adder<StatusDetection>());
  	deployTemperatureDetections(new Adder<TemperatureDetection>());
  	deploySmokeDetections(new Adder<SmokeDetection>());
  	deployAlertDetections(new Adder<AlertDetection>());
  	deployBuildingAlertDetections(new Adder<BuildingAlertDetection>());

  	deployAlarmManagers(new Adder<AlarmManager>());
  	deployLogManagers(new Adder<LogManager>());
  	deployMessageManagers(new Adder<MessageManager>());

  }

}